<!--
+----------------------------------------------------------------------
| 友得云客  - 开启房产营销新纪元
+----------------------------------------------------------------------
| Copyright (c) 2019~2023 优得（西安）信息科技有限公司版权所有
+----------------------------------------------------------------------
| Licensed 友得云客不是自由软件 未经允许不可移除相关版权
+----------------------------------------------------------------------
| Author: www.youdeyunke.com
+----------------------------------------------------------------------
-->
<template>
    <div v-loading="loading">
        <el-tabs :stretch="true" v-model="activeTab">
            <el-tab-pane label="基础" name="base">
                <transfer :titles="['待选文章', '已选文章']" :data="items" v-model="module.items"
                    :props="{ key: 'id', label: 'title' }" />


            </el-tab-pane>

            <el-tab-pane label="样式" name="style">
                <el-form-item style="margin-top: 20px" label="图标">
                    <image-picker width="30" height="30" v-model="iconUrl" />
                </el-form-item>

                <el-form-item label="字体颜色">
                    <el-color-picker v-model="module.data.fontColor" size="mini"></el-color-picker>
                </el-form-item>

                <el-form-item label="字体大小">
                    <el-input-number v-model="module.data.fontSize" :min="24" :max="36" size="mini"></el-input-number>
                </el-form-item>

                <module-style-editor :module="module" />
            </el-tab-pane>
        </el-tabs>
    </div>
</template>

<script>
import Transfer from "@/components/Transfer";
import ModuleStyleEditor from "./ModuleStyleEditor/Index";
import { getNewsList } from "@/api/news";
import ImagePicker from "@/components/ImagePicker";

export default {
    components: {
        Transfer,
        ImagePicker,
        ModuleStyleEditor,
    },
    props: {
        module: { type: Object },
    },
    computed: {
        iconUrl: {
            get () {
                var defaultIcon = "https://tcdn.udeve.net/assets/icons/search-icon.png";
                return this.module.data.icon ? this.module.data.icon : defaultIcon;
            },
            set (url) {
                this.$set(this.module.data, "icon", url);
            },
        },
    },
    data () {
        return {
            ids: [],
            items: [],
            loading: false,
            activeTab: "base",
        };
    },
    mounted: function () {
        this.loadData();
    },

    methods: {
        loadData: function () {
            this.loading = true;
            var params = { simple_list: true, scope: "public_items" };
            getNewsList(params).then((res) => {
                this.loading = false;
                if (res.status != 0) {
                    return false;
                }
                this.items = res.data.result;
            });
        },
    },
};
</script>

<style scoped>
.styles {
    list-style: none;
    display: flex;
    justify-content: flex-start;
    align-content: center;
    flex-wrap: wrap;
    margin: 0;
    padding: 0;
}

.styles li {
    width: 100px;
    height: 80px;
    border: 1px solid #fff;
    border-radius: 10px;
    margin-right: 10px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-content: center;
}

.styles li:hover {
    border: 1px solid #f4f4f4;
}

.styles li.active {
    border: 1px solid #1989fa;
}
</style>
